import java.util.ArrayList;
import java.util.List;

public class main {

    public static void main(String[] args) {
        Solution.lexicalOrder(15);
    }

    static class Solution {
        public static List<Integer> lexicalOrder(int n) {
            List<Integer> result = new ArrayList<Integer>();
            for(int i=1;i<=9;i++){
                fn(result,i,n);
            }
            return null;
        }

        public static boolean  fn(List<Integer> list,int tmp,int n){
            if(tmp>n){
                return false;
            }
            list.add(tmp);
            for(int i=tmp*10;i<(tmp+1)*10;i++){
                if(!fn(list,i,n)){
                    break;
                }
            }
            return true;
        }
    }
}
